package com.yike.user.controller;

import com.yike.user.entity.MessageReminder;
import com.yike.user.service.MessageReminderService;
import com.yike.user.vo.MessageReminderDateVo;
import com.yike.user.vo.MessageReminderInfoVo;
import lombok.extern.slf4j.Slf4j;
import com.yike.user.param.MessageReminderPageParam;
import com.yike.common.base.BaseController;
import com.yike.common.api.ApiResult;
import com.yike.common.pagination.Paging;
import com.yike.common.api.IdParam;
import com.yike.common.log.Module;
import com.yike.common.log.OperationLog;
import com.yike.common.enums.OperationLogType;
import com.yike.common.api.Add;
import com.yike.common.api.Update;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 消息提醒表 控制器
 *
 * @author Sakura
 * @since 2024-09-24
 */
@Slf4j
@RestController
@RequestMapping("/messageReminder")
@Module("user")
@Api(value = "消息提醒API", tags = {"消息提醒管理"})
public class MessageReminderController extends BaseController {

    @Autowired
    private MessageReminderService messageReminderService;

    @PostMapping("/getMessageReminderList")
    //@OperationLog(name = "获取消息提醒列表（全部）", type = OperationLogType.PAGE)
    @ApiOperation(value = "获取消息提醒列表（全部）", response = MessageReminderDateVo.class)
    public ApiResult<List<MessageReminderDateVo>> getMessageReminderList() throws Exception {
        List<MessageReminderDateVo> messageReminderDateVos = messageReminderService.getMessageReminderList();
        return ApiResult.ok(messageReminderDateVos);
    }

    /**
     * 消息提醒表分页列表
     */
    @PostMapping("/getPageList")
    //@OperationLog(name = "消息提醒表分页列表", type = OperationLogType.PAGE)
    @ApiOperation(value = "消息提醒表分页列表", response = MessageReminderInfoVo.class)
    public ApiResult<Paging<MessageReminderInfoVo>> getMessageReminderPageList(@Validated @RequestBody MessageReminderPageParam messageReminderPageParam) throws Exception {
        Paging<MessageReminderInfoVo> paging = messageReminderService.getMessageReminderPageList(messageReminderPageParam);
        return ApiResult.ok(paging);
    }

    @PostMapping("/getMessageReminderCount")
    //@OperationLog(name = "获取消息提醒数量", type = OperationLogType.PAGE)
    @ApiOperation(value = "获取消息提醒数量", response = ApiResult.class)
    public ApiResult<Integer> getMessageReminderCount() throws Exception {
        Integer count = messageReminderService.getMessageReminderCount();
        return ApiResult.ok(count);
    }

    @PostMapping("/read/{id}")
    //@OperationLog(name = "已读", type = OperationLogType.PAGE)
    @ApiOperation(value = "已读", response = ApiResult.class)
    public ApiResult<Boolean> read(@PathVariable("id") Long id) throws Exception {
        boolean flag = messageReminderService.read(id);
        return ApiResult.result(flag);
    }

}

